﻿using System.Collections.Generic;

namespace System.Xml.Linq
{
    ///<summary>
    /// Contains extension methods for System.Xml.Linq.
    ///</summary>
    public static class ExtensionMethods
    {
        ///<summary>
        /// Extends the Elements method so that it accepts a namespace.
        ///</summary>
        ///<param name="source">The XElement.</param>
        ///<param name="ns">The namespace to use.</param>
        ///<param name="name">The name to receive from.</param>
        ///<returns>An IEnumerable with the result.</returns>
        public static IEnumerable<XElement> Elements(this XContainer source, XNamespace ns, string name)
        {
            return source.Elements(ns + name);
        }

        ///<summary>
        /// Extends the Element method so that it accepts a namespace.
        ///</summary>
        ///<param name="source">The XElement.</param>
        ///<param name="ns">The namespace to use.</param>
        ///<param name="name">The name to receive from.</param>
        ///<returns>An XElement with the result.</returns>
        public static XElement Element(this XContainer source, XNamespace ns, string name)
        {
            return source.Element(ns + name);
        }
    }
}